import React from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'

import * as personActions from '../store/actions/personActions'

function Person(props) {
  console.log(props.person.person, '000000')
  let person = props.person.person
  return (
    <div>
      <button onClick={() => { props.addPerson({ id: 2, name: '123' }) }}>添加</button>
      <ul>
        {
          person.map(p => {
            return <li key={p.id}>{p.name}</li>
          })
        }
      </ul>
    </div>
  )
}

const mapDispatchToProps = dispatch => ({
  ...bindActionCreators(personActions, dispatch)
})

const mapStateToProps = state => ({
  person: state.person
})

export default connect(mapStateToProps, mapDispatchToProps)(Person)